import {request} from "@umijs/max";
import {ResponseStructure} from "@/requestErrorConfig";

export async function pageUser(
  params: {
    current?: number;
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<ResponseStructure>('/api/user/page', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

export async function updateUserById(data: API.CurrentUser, options?: { [key: string]: any },) {
  return request<ResponseStructure>('/api/user/updateById', {
    method: 'PUT',
    data,
    ...(options || {}),
  });
}

export async function deleteUserById(id: string | number, options?: { [key: string]: any },) {
  return request<ResponseStructure>(`/api/user/${id}`, {
    method: 'DELETE',
    ...(options || {}),
  });
}

export async function addUser(data: API.CurrentUser, options?: DynamicObject,) {
  return request<ResponseStructure>('/api/user', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}
